home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / Textra116 / Scripts / HSPascal_Scripts / HScompile.textra
Encoding:
Text File  |  1996-09-27  |  4.0 KB  |  128 lines

  1. /***********************************************************************
  2. * Launching HSPC HiSpeed Pascal compiler from Textra. This             *
  3. * script first saves the Pascal source file to disk, then              *
  4. * compiles it to RAM:                                                  *
  5. *                                                                      *
  6. * A nice AREXX script that compiles HSPascal from my favorite text     *
  7. * editor, Textra.                                                      *
  8. *                                                                      *
  9. * The script first saves the source code to disk.                      *
  10. * Then it calls the HSPascal compiler to compile the file.             *
  11. * If the compiler detects errors,                                      *
  12. * Textra reads in the error file, parses it for the line number of the *
  13. * error, reports it, jumps back to the source code file, and sends        *
  14. * the cursor to the offending line number.                             *
  15. ***********************************************************************/
  16.  
  17. /***********************************************************************
  18. * You can order Textra from:                                           *
  19. * Mike Haas                                                            *
  20. * 3867 La Colina Road                                                  *
  21. * El Sobrante, CA 94803                                                *
  22. ***********************************************************************/
  23.  
  24. /***********************************************************************
  25. * Nick Didkovsky, 72250.3313@compuserve.com                            *
  26. *  9/24/92                                                             *
  27. ***********************************************************************/
  28.  
  29. /* MOD: handles volume names with blanks now 1/5/93 */
  30. /* MOD: (mdh) moved address TEXTRA past version check 1/6/93 */
  31. /* MOD: Parses $0D iin error file correctly now 1/7/93 */
  32.  
  33. options results
  34.  
  35.  
  36. /*check Textra version*/
  37. rex = 0; result = "NOTSUPPORTED"
  38. address 'TEXTRA' 'textraversion'
  39. parse var result maj min rex
  40. if (result == "NOTSUPPORTED") | (rex < 3) then do
  41.         address 'TEXTRA' 'notify "Textra V1.13 or later required for this script."'
  42.         exit
  43. end
  44.  
  45. address 'TEXTRA'
  46.  
  47. GET file name
  48. fname = result
  49. GET file path
  50. pname = result
  51. fullname = pname || fname
  52.  
  53. IF fname == 'Untitled'
  54. THEN DO
  55.         notify 'Cannot compile Untitled source code'
  56.         notify 'Please name this file by selecting SAVE FILE AS'
  57.         exit
  58.     END
  59.     
  60. saveas fullname
  61.  
  62. IF ~(result == 'OK' )
  63. THEN DO
  64.         notify 'trouble'
  65.         exit
  66.     END
  67.  
  68.  
  69. /* Check your HSPascal manual for the appropriate HSPC options for your system
  70.    and change the following Options accordingly.  */
  71.    
  72. Opts1 = '-$M25,1,350,15 -M -$D+ -$L+ -ERAM:'
  73. Opts2 = '-Ihsp:Include -Uhspunits2: -DWORKBENCH_2'
  74. CompileCommand = 'hsp:hspc >t:err ' || Opts1 || ' ' || Opts2  || ' ' || '"'fullname'"'
  75. say CompileCommand
  76.  
  77. address command
  78.  
  79. CompileCommand
  80.  
  81. address 'TEXTRA'
  82. IF rc=10
  83. THEN
  84.     DO
  85.         OPENFILE 't:err'
  86.         wp = result
  87.         top
  88.         /* Find the line in  the error file which notifies which error occurred */
  89.         find 'error'
  90.         UNSELECT
  91.         GET cursor position
  92.         parse var result x ' ' y
  93.         /* notify 'error found at pos' x ' line ' y */
  94.         SELECTLINE  y
  95.          GET select text
  96.          parse var result junk ' ' TheLine
  97.          unselect
  98.          parse var TheLine FirstPart '0D'x TheRest
  99.          /*     notify 'FirstPart=' FirstPart
  100.              notify 'TheREst=' TheRest
  101.              notify (TheRest ~== '')
  102.          */
  103.          IF (TheRest ~== '')
  104.          THEN DO     
  105.                  /* notify 'doing the rest' */ /* keep DO alone on a line */
  106.                    TheLine = TheRest
  107.              END
  108.          ELSE DO       
  109.                  /* notify 'doing the line' */    /* keep DO alone on a line */
  110.                    TheLine = FirstPart
  111.              END
  112.          parse var TheLine junk '(' LineNum ')' junk2
  113.          parse var TheLine junk 'Error' TheError
  114.          
  115.          CLOSEWINDOW
  116.         FINDFILE fullname
  117.         wp = result
  118.         IF wp==0
  119.         THEN notify 'Can''t find filewindow in Textra'
  120.         ELSE DO 
  121.             selectwindow wp
  122.             GOTOXY 0 LineNum-1
  123.             NOTIFY 'Error' TheError 'on line' LineNum
  124.         END
  125.     END
  126.  
  127. ELSE NOTIFY 'Compiled successfully to RAM:'
  128.